/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package project.ejbs;

import java.util.List;
import javax.ejb.Stateless;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
import javax.persistence.Query;
import project.entity.Revisao;

/**
 *
 * @author serafim
 */
@Stateless
public class RevisaoFacade extends AbstractFacade<Revisao> {
    @PersistenceContext(unitName = "DAEPU")
    private EntityManager em;

    protected EntityManager getEntityManager() {
        return em;
    }

    public RevisaoFacade() {
        super(Revisao.class);
    }

    public int countRevisor(String username) {
        Query cq = getEntityManager().createNamedQuery("listaRevisor");
        cq.setParameter("username", username);
        List lb = cq.getResultList();
        return lb.size();
    }

    public int countSubmissao(long idSubmissao) {
        Query cq = getEntityManager().createNamedQuery("listaSubmissao");
        cq.setParameter("idSubmissao", idSubmissao);
        List lb = cq.getResultList();
        return lb.size();
    }
    
    public List<Revisao> searchRevisor(int[] range, String username) {
        Query cq = getEntityManager().createNamedQuery("listaRevisor");
        cq.setParameter("username", username);
        List lb = cq.getResultList();
        return lb;
    }

    public List<Revisao> searchSubmissao(int[] range, long idSubmissao) {
        Query cq = getEntityManager().createNamedQuery("listaSubmissao");
        cq.setParameter("idSubmissao", idSubmissao);
        List lb = cq.getResultList();
        return lb;
    }

    public List searchRevisorSubmissao(long idSubmissao) {
        Query cq = getEntityManager().createNamedQuery("listaRevisoresSubmissao");
        cq.setParameter("idSubmissao", idSubmissao);
        List lb = cq.getResultList();
        return lb;
    }
    
}
